﻿package mortal.game.resource.tableConfig
{
    import Message.DB.Tables.*;
    import com.gengine.resource.*;
    import flash.utils.*;
    import mortal.game.view.common.*;

    public class EquipJewelMatchConfig extends Object
    {
        private var _map:Dictionary;
        private var _list:Array;
        private static var _instance:EquipJewelMatchConfig;

        public function EquipJewelMatchConfig()
        {
            this._map = new Dictionary();
            this._list = new Array();
            if (_instance != null)
            {
                throw new Error(" EquipJewelMatchConfig 单例 ");
            }
            this.init();
            return;
        }// end function

        public function init() : void
        {
            var _loc_1:* = ConfigManager.instance.getJSONByFileName("t_equip_jewel_match.json");
            this.write(_loc_1);
            return;
        }// end function

        private function write(param1:Object) : void
        {
            var _loc_2:TEquipJewelMatch = null;
            var _loc_3:Object = null;
            for each (_loc_3 in param1)
            {
                
                _loc_2 = new TEquipJewelMatch();
                ClassTypesUtil.copyValue(_loc_2, _loc_3);
                this._list.push(_loc_2);
            }
            return;
        }// end function

        public function getInfoByType(param1:int, param2:String = "jewel") : TEquipJewelMatch
        {
            var _loc_3:TEquipJewelMatch = null;
            for each (_loc_3 in this._list)
            {
                
                if (_loc_3.equiptype == param1 && _loc_3.recordType == param2)
                {
                    return _loc_3;
                }
            }
            return null;
        }// end function

        public function getEquipTypeByJewelType(param1:int, param2:String = "jewel") : Array
        {
            var _loc_4:TEquipJewelMatch = null;
            var _loc_3:Array = [];
            for each (_loc_4 in this._list)
            {
                
                if (_loc_4.jeweltype == param1 && _loc_4.recordType == param2)
                {
                    _loc_3.push(_loc_4.equiptype);
                }
            }
            return _loc_3;
        }// end function

        public function getJewelTypeByEquipType(param1:int, param2:String = "jewel") : int
        {
            var _loc_3:TEquipJewelMatch = null;
            for each (_loc_3 in this._list)
            {
                
                if (_loc_3.equiptype == param1 && _loc_3.recordType == param2)
                {
                    return _loc_3.jeweltype;
                }
            }
            return -1;
        }// end function

        public function getNameByJewelType(param1:int, param2:String = "jewel") : String
        {
            var _loc_3:TEquipJewelMatch = null;
            for each (_loc_3 in this._list)
            {
                
                if (_loc_3.jeweltype == param1 && _loc_3.recordType == param2)
                {
                    return _loc_3.desc;
                }
            }
            return null;
        }// end function

        public static function get instance() : EquipJewelMatchConfig
        {
            if (_instance == null)
            {
                _instance = new EquipJewelMatchConfig;
            }
            return _instance;
        }// end function

    }
}
